<template>
  <view class="table">
    <new-table
      :table-data="data"
      :width="minTableWidth"
      :height="dataCount * 100 + 100"
      :header-height="100"
      :cell-height="100"
      :cell-width="cellWidth"
      stripe
      @row-click="hdClick"
    />
  </view>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import NewTable from '@/tmui/components/tm-table/newTable.vue'
import { cellWidth, minTableWidth } from '@/utils/fontSizeHandler'
const props = defineProps<{
  data: TableDataType
}>()

const emit = defineEmits<{
  (e: 'update', index: number): void
  (e: 'delete', index: number): void
}>()

const dataCount = computed(() => props.data.data.length)

const hdClick = (row: number, col: number) => {
  if (col === 0) {
    emit('update', row)
  } else if (col === 1) {
    emit('delete', row)
  }
}
</script>

<style scoped lang="scss">
.table {
  display: flex;
  flex-direction: column;
  // justify-content: center;
}
</style>
